﻿Public Partial Class Wfrm_Master
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Anthem.Manager.Register(Me)


        'If Session("usuario") Is Nothing Then
        '    If Anthem.Manager.IsCallBack Then
        '        Anthem.Manager.AddScriptForClientSideEval("try {self.parent.location ='../Inicio.aspx';}catch(ex){}")
        '    Else
        '        Page.ClientScript.RegisterStartupScript(Me.GetType, "inicio", "<script> try {self.parent.location ='../Inicio.aspx';}catch(ex){} </script>")
        '    End If
        'Else
        '    Anthem.Manager.AddScriptForClientSideEval("try {parent.resize();}catch(ex){}")
        'End If

        'Anthem.Manager.AddScriptForClientSideEval("$("".campofecha"").calendarioDW();")
    End Sub

    Sub MsgError(ByVal Mensaje As String)
        Mensaje = Mensaje.Replace("'", "").Replace("<", "").Replace(">", "")
        ' Anthem.Manager.AddScriptForClientSideEval("jError('" & Mensaje & "', 'Error');")

        If Anthem.Manager.IsCallBack Then
            Anthem.Manager.AddScriptForClientSideEval("jError('" & Mensaje & "', 'Error');")
        Else
            Page.ClientScript.RegisterStartupScript(Me.GetType, "jError_call", "<script>jError('" & Mensaje & "', 'Error');</script>")

        End If

    End Sub
    Sub MsgInformativo(ByVal Mensaje As String)
        Mensaje = Mensaje.Replace("'", "").Replace("<", "").Replace(">", "")

        If Anthem.Manager.IsCallBack Then
            Anthem.Manager.AddScriptForClientSideEval("jAlert('" & Mensaje & "', 'Información');")
        Else
            Page.ClientScript.RegisterStartupScript(Me.GetType, "jAlert_call", "<script>jAlert('" & Mensaje & "', 'Información');</script>")

        End If

    End Sub
    Sub MsgConfirm(ByVal Mensaje As String, ByVal funcionJ As String)
        Mensaje = Mensaje.Replace("'", "").Replace("<", "").Replace(">", "")
        'Anthem.Manager.AddScriptForClientSideEval("jConfirm('" & Mensaje & "', 'Confirmación','" & funcionJ & "');")


        If Anthem.Manager.IsCallBack Then
            Anthem.Manager.AddScriptForClientSideEval("jConfirm('" & Mensaje & "', 'Confirmación');")
        Else
            Page.ClientScript.RegisterStartupScript(Me.GetType, "jConfirm_call", "<script>jConfirm('" & Mensaje & "', 'Confirmación');</script>")

        End If

    End Sub

    Sub ExecuteSP(ByRef rp As DotNetResponse.SQLPersistence, ByVal commit As Boolean, ByVal returnValue As Boolean)
        Dim exec As New DotNetDal.SQLPersistence(commit, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        If returnValue Then
            exec.ExecuteDataTable(rp)
            If commit Then
                exec.Commit()
            End If
        Else
            exec.ExecuteNonQuery(rp)
            exec.Commit()
        End If

    End Sub
    Sub Carga_CMB_Concepto(ByRef Cmb As Anthem.DropDownList, ByVal SP As String, Optional ByVal parametros() As String = Nothing)
        Dim rp As New DotNetResponse.SQLPersistence
        If Not parametros Is Nothing Then
            rp.Parametro = parametros
        End If
        rp.StoredProcedure = SP
        ExecuteSP(rp, False, True)
        If Not rp.Errores Then
            Cmb.DataTextField = "S_TEXTO"
            Cmb.DataValueField = "ID_CONCEPTO"
            Cmb.DataSource = rp.DtTable
            Cmb.DataBind()
        Else
            MsgError(rp.MensajeError)
        End If
    End Sub

End Class